package com.tiancheng.onecode.model.response;

import java.util.LinkedList;
import java.util.List;

/**
 * 分页信息
 */
public class PageInfo<T> {
	private List<T> list;
	private long currentPage;
	private long pageSize;
	private long total;
	private Long totalPage;

	public PageInfo() {
		this.currentPage = 1L;
		this.pageSize = 0;
		this.total = 0L;
		this.totalPage = 0L;
	}

	public PageInfo(long currentPage, long pageSize, long total,List<T> list) {
		this.currentPage = currentPage;
		this.pageSize = pageSize;
		this.total = total;
		this.list=list;
	}
	public PageInfo(long currentPage, long pageSize, long total) {
		this.currentPage = currentPage;
		this.pageSize = pageSize;
		this.total = total;
	}

	public long getTotalPage() {
		if (this.totalPage == null || this.totalPage == 0L) {
			this.totalPage = this.total / (long)this.pageSize;
			if (this.total % (long)this.pageSize != 0L) {
				Long var1 = this.totalPage;
				Long var2 = this.totalPage = this.totalPage + 1L;
			}
		}

		return this.totalPage;
	}

	public long getCurrentPage() {
		return this.currentPage;
	}

	public long getPageSize() {
		return this.pageSize;
	}

	public long getTotal() {
		return this.total;
	}

	public void setCurrentPage(long currentPage) {
		this.currentPage = currentPage;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public void setTotal(long total) {
		this.total = total;
	}

	public void setTotalPage(Long totalPage) {
		this.totalPage = totalPage;
	}

	public List<T> getList() {
		if (this.list == null) {
			this.list = new LinkedList();
		}

		return this.list;
	}
	public void setList(List<T> list) {
		this.list = list;
	}
}
